{"ast":null,"code":"var _jsxFileName = \"/data/messenger.client/src/components/Avatar/index.tsx\",\n  _s = $RefreshSig$();\nimport React from \"react\";\nimport { generateAvatarByNickname } from \"../../utils/helpers\";\nimport './Avatar.scss';\nimport { Carousel } from \"../index\";\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nimport { Fragment as _Fragment } from \"react/jsx-dev-runtime\";\nconst Avatar = _ref => {\n  _s();\n  let {\n    contentList,\n    alt,\n    stringForGenerateColor,\n    stringForFirstCharacter,\n    shortAvatar = true\n  } = _ref;\n  const [collection, setCollection] = React.useState();\n  React.useEffect(() => {\n    if (!shortAvatar && contentList !== null && contentList !== void 0 && contentList.items.length) {\n      setCollection(contentList.items.map((item, index) => {\n        return /*#__PURE__*/_jsxDEV(_Fragment, {\n          children: /*#__PURE__*/_jsxDEV(\"img\", {\n            className: \"avatar\",\n            src: item.link,\n            alt: 'Avatar ' + alt\n          }, item.id || index, false, {\n            fileName: _jsxFileName,\n            lineNumber: 16,\n            columnNumber: 29\n          }, this)\n        }, void 0, false);\n        console.log(index);\n      }));\n    }\n  }, [contentList]);\n  if (contentList && contentList.items && contentList.items.length > 0 && shortAvatar) {\n    return /*#__PURE__*/_jsxDEV(\"img\", {\n      className: \"avatar\",\n      src: contentList.items[0].link,\n      alt: 'Avatar ' + alt\n    }, void 0, false, {\n      fileName: _jsxFileName,\n      lineNumber: 27,\n      columnNumber: 13\n    }, this);\n  } else if (shortAvatar) {\n    const {\n      colors\n    } = generateAvatarByNickname(stringForGenerateColor);\n    const firstChar = stringForFirstCharacter[0].toUpperCase();\n    return /*#__PURE__*/_jsxDEV(\"div\", {\n      style: {\n        background: `linear-gradient(135deg, ${colors.color} 0%, ${colors.colorLighten} 96.52%)`\n      },\n      className: \"avatar avatar--symbol\",\n      children: firstChar\n    }, void 0, false, {\n      fileName: _jsxFileName,\n      lineNumber: 34,\n      columnNumber: 13\n    }, this);\n  } else {\n    if (contentList && collection) {\n      return /*#__PURE__*/_jsxDEV(Carousel, {\n        width: 200,\n        children: collection\n      }, void 0, false, {\n        fileName: _jsxFileName,\n        lineNumber: 44,\n        columnNumber: 17\n      }, this);\n    } else {\n      return /*#__PURE__*/_jsxDEV(_Fragment, {}, void 0, false);\n    }\n  }\n};\n_s(Avatar, \"yLO8Y52DhYbDdJIx8Q02Tm4qRjk=\");\n_c = Avatar;\nexport default Avatar;\nvar _c;\n$RefreshReg$(_c, \"Avatar\");","map":{"version":3,"names":["React","generateAvatarByNickname","Carousel","Avatar","contentList","alt","stringForGenerateColor","stringForFirstCharacter","shortAvatar","collection","setCollection","useState","useEffect","items","length","map","item","index","link","id","console","log","colors","firstChar","toUpperCase","background","color","colorLighten"],"sources":["/data/messenger.client/src/components/Avatar/index.tsx"],"sourcesContent":["import React from \"react\";\nimport {AvatarProps} from \"../../models/props/AvatarProps\";\nimport { generateAvatarByNickname } from \"../../utils/helpers\";\nimport './Avatar.scss';\nimport {Carousel} from \"../index\";\n\nconst Avatar: React.FC<AvatarProps> = ({contentList, alt, stringForGenerateColor, stringForFirstCharacter, shortAvatar = true}) => {\n    const [collection, setCollection] = React.useState<React.ReactNode |React.ReactNode[]>();\n\n    React.useEffect(() => {\n        if (!shortAvatar && contentList?.items.length!) {\n            setCollection(\n                contentList.items.map((item, index) => {\n                    return (\n                        <>\n                            <img key={item.id || index} className='avatar' src={item.link} alt={'Avatar ' + alt}/>\n                        </>\n                    );\n                    console.log(index)\n                })\n            );\n        }\n    }, [contentList]);\n\n    if (contentList && contentList.items && contentList.items.length > 0 && shortAvatar) {\n        return (\n            <img className='avatar' src={contentList.items[0].link} alt={'Avatar ' + alt}/>\n        );\n    } else if (shortAvatar) {\n        const {colors} = generateAvatarByNickname(stringForGenerateColor);\n        const firstChar = stringForFirstCharacter[0].toUpperCase();\n\n        return (\n            <div\n                style={{background: `linear-gradient(135deg, ${colors.color} 0%, ${colors.colorLighten} 96.52%)`}}\n                className='avatar avatar--symbol'\n            >\n                {firstChar}\n            </div>\n        );\n    } else {\n        if (contentList && collection!) {\n            return (\n                <Carousel width={200} >\n                    {collection}\n                </Carousel>\n            );\n        } else {\n            return <></>;\n        }\n    }\n}\n\nexport default Avatar;\n"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,wBAAwB,QAAQ,qBAAqB;AAC9D,OAAO,eAAe;AACtB,SAAQC,QAAQ,QAAO,UAAU;AAAC;AAAA;AAElC,MAAMC,MAA6B,GAAG,QAA6F;EAAA;EAAA,IAA5F;IAACC,WAAW;IAAEC,GAAG;IAAEC,sBAAsB;IAAEC,uBAAuB;IAAEC,WAAW,GAAG;EAAI,CAAC;EAC1H,MAAM,CAACC,UAAU,EAAEC,aAAa,CAAC,GAAGV,KAAK,CAACW,QAAQ,EAAsC;EAExFX,KAAK,CAACY,SAAS,CAAC,MAAM;IAClB,IAAI,CAACJ,WAAW,IAAIJ,WAAW,aAAXA,WAAW,eAAXA,WAAW,CAAES,KAAK,CAACC,MAAO,EAAE;MAC5CJ,aAAa,CACTN,WAAW,CAACS,KAAK,CAACE,GAAG,CAAC,CAACC,IAAI,EAAEC,KAAK,KAAK;QACnC,oBACI;UAAA,uBACI;YAA4B,SAAS,EAAC,QAAQ;YAAC,GAAG,EAAED,IAAI,CAACE,IAAK;YAAC,GAAG,EAAE,SAAS,GAAGb;UAAI,GAA1EW,IAAI,CAACG,EAAE,IAAIF,KAAK;YAAA;YAAA;YAAA;UAAA;QAA4D,iBACvF;QAEPG,OAAO,CAACC,GAAG,CAACJ,KAAK,CAAC;MACtB,CAAC,CAAC,CACL;IACL;EACJ,CAAC,EAAE,CAACb,WAAW,CAAC,CAAC;EAEjB,IAAIA,WAAW,IAAIA,WAAW,CAACS,KAAK,IAAIT,WAAW,CAACS,KAAK,CAACC,MAAM,GAAG,CAAC,IAAIN,WAAW,EAAE;IACjF,oBACI;MAAK,SAAS,EAAC,QAAQ;MAAC,GAAG,EAAEJ,WAAW,CAACS,KAAK,CAAC,CAAC,CAAC,CAACK,I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